package org.jeecg.jt808.processor;


import org.jeecg.jt808.operate.*;

import java.util.HashMap;
import java.util.Map;


public class JT808MessageGeneratorFactory {
    private static final Map<String, JT808MessageGenerator> generators = new HashMap<>();

   /* @Autowired
    public JT808MessageGeneratorFactory(List<JT808MessageGenerator> strategies) {
        for (JT808MessageGenerator strategy : strategies) {
            generators.put(strategy.getType(), strategy);
        }
    }

    public static JT808MessageGenerator getGenerator(String type) {
        return generators.get(type);
    }*/

    public JT808MessageGenerator getGenerator(MessageType messageType) {
        switch (messageType) {

            case QUERY_LOCATION:
                return new QueryLocationMessage(); // 或 LocationQueryMessageGenerator，取决于你的类名
            case LOCATION_TRACK:
                return new LocationTrackMessageGenerator();
            case HANDLE_LOCK_OPEN:
                return new HandleLockOpenMessageGenerator();
            case HANDLE_LOCK_CLOSE:
                return new HandleLockCloseMessageGenerator();
            case DISARMING_CAR:
                return new DisarmingCarMessageGenerator();
            case DEFENSE_CAR:
                return new DefenseCarMessageGenerator();
            case CLEAR_REMOTE_CONTROL:
                return new ClearRemoteControlMessageGenerator();
            case OPEN_CAR:
                return new VehicleOpenMessageGenerator();
            case CLOSE_CAR:
                return new VehicleCloseMessageGenerator();
            case SEARCH_CAR:
                return new SearchingCarMessageGenerator();
            case SET_SPEED_LIMIT:
                return new SetSpeedLimitMessageGenerator();
            case REMOTE_CONTROL_PAIR:
                return new RemoteControlPairMessageGenerator();
            case SEAT_LOCK:
                return new SeatLockMessageGenerator();
            // ... other cases
            default:
                throw new IllegalArgumentException("不支持的消息类型: " + messageType);
        }
    }



    public JT808MessageGenerator getGenerator(String type) {
        return generators.get(type);
    }


    public JT808MessageGenerator createGenerator(MessageType type) {
        return generators.get(type);
    }
}
